package com.cxf.windex.rest.minaf;

import com.cxf.windex.base.msg.TableResultResponse;
import com.cxf.windex.base.rest.BaseRestController;
import com.cxf.windex.biz.TjShopBiz;
import com.cxf.windex.entity.BShop;
import com.cxf.windex.entity.TjShop;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 推广店铺
 *
 * @author chenxf
 * @version 1.0
 * @date 2019-01-02 11:07
 **/
@Api(tags = {"村广通[小程序-福] - 推广店铺接口"})
@Controller
@RequestMapping("userf/tjshop")
public class TjShopController extends BaseRestController<TjShopBiz, TjShop> {

    @ApiOperation(value = "查询推广店铺", notes = "查询推广店铺")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "limit", value = "记录数 默认10",   paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "offset", value = "页码 默认 1",   paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "orderStr", value = "排序 默认desc",   paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "openid", value = "推广人openid",   paramType = "query", dataType = "String"),
    })
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    public TableResultResponse<TjShop> list(
            @RequestParam(defaultValue = "10") int limit, @RequestParam(defaultValue = "1") int offset,
            @RequestParam(defaultValue = "desc") String orderStr, String openid) {
        List<TjShop> items = baseBiz.list(limit, offset, orderStr,  openid);
        PageInfo<TjShop> pageInfo = new PageInfo<>(items);
        return new TableResultResponse<>(Integer.parseInt(String.valueOf(pageInfo.getTotal())),
                offset, limit,
                items);
    }
}
